#include <bits/stdc++.h>
using namespace std;
const int maxn = 10006;
int n;
int p[maxn][4];
int x, y;
int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
#endif
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin>>n;
  for(int i=0; i<n; ++i)
    for(int j=0; j<4; ++j)
      cin>>p[i][j];
  cin>>x>>y;
  for(int i=n-1; i>=0; --i) {
    auto [a, b, g, k] = p[i];
    if(a<=x && x<=a+g && b<=y && y<=b+k) {
      cout<<i+1<<'\n';
      return 0;
    }
  }
  cout<<"-1\n";
  return 0;
}

